#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int T, n, m, L, V, p[N], cnt[N];
struct Node {
    int x0, v0, a;
} car[N];
bool vis[N];
vector<pair<int, int> > vec;
signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while (T--) {
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) cin >> car[i].x0 >> car[i].v0 >> car[i].a;
        for (int i = 1; i <= m; i++) cin >> p[i];
        int res = 0, sum = 0;
        vec.clear();
        memset(vis, false, sizeof(vis));
        memset(cnt, 0, sizeof(cnt));
        for (int i = 1; i <= n; i++) {
            if (car[i].v0 <= V && car[i].a <= 0 || car[i].x0 > p[m]) continue;
            if (car[i].v0 > V && car[i].a >= 0) {
                res++;
                int beg = lower_bound(p + 1, p + 1 + m, car[i].x0) - p;
                vec.push_back(make_pair(beg, m));
                vis[m] = true;
                continue;
            }
            if (car[i].a < 0) {
                long double x = (V * V - car[i].v0 * car[i].v0) / (2.0 * car[i].a);
                int beg = lower_bound(p + 1, p + 1 + m, car[i].x0) - p;
                if (car[i].x0 + x > p[beg]) {
                    res++;
                    vis[beg] = true;
                    int end = lower_bound(p + 1, p + 1 + m, car[i].x0 + x) - p - 1;
                    vec.push_back(make_pair(beg, end));
                    vis[beg] = true;
                }
            } else {
                long double x = (V * V - car[i].v0 * car[i].v0) / (2.0 * car[i].a);
                if (car[i].x0 + x < p[m]) {
                    res++;
                    int beg = upper_bound(p + 1, p + 1 + m, car[i].x0 + x) - p;
                    vec.push_back(make_pair(beg, m));
                    vis[m] = true;
                }
            }
        }
        for (int i = 1; i <= m; i++) if (!vis[i]) sum++;
        cout << res << ' ' << sum << '\n';
    }
    return 0;
}